$(document).ready(function () {
    var productIntroBox = $(".product-intro-box");
    for(var i=0;i<3;i++){
        $(".product-intro-item").eq(i).clone().appendTo(productIntroBox);
    }
    console.log($(".product-intro-box").width());
    var productIntroBoxW = $(".product-intro-item").length*180;
    var slider = function () {
        var productIntroBoxML = productIntroBox.css("margin-left");
        productIntroBox.animate({marginLeft:(parseInt(productIntroBoxML) - 210) + "px"},1000,function () {
            if(630-productIntroBoxW >= parseInt(productIntroBoxML)){
                productIntroBox.css("margin-left","0px");
            }
        })
    }
    var timer = setInterval(slider,3000);
    productIntroBox.mouseover(function () {
        clearInterval(timer)
    })
    productIntroBox.mouseout(function () {
        timer = setInterval(slider,3000);
    })
    $(".product-intro-nextbtn").on("click",function () {
        clearInterval(timer);
        var productIntroBoxML = productIntroBox.css("margin-left");
        productIntroBox.animate({marginLeft:(parseInt(productIntroBoxML) + 210) + "px"},1000,function () {
            productIntroBoxML = productIntroBox.css("margin-left");
            if(parseInt(productIntroBoxML) >= 0){
                productIntroBox.css("margin-left",-productIntroBoxW+390+"px");
            }
        })
    })
})